home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1999 March / EnigmA AMIGA RUN 35 (1999)(G.R. Edizioni)(IT)[!][issue 1999-03].iso / earcd / emul / cp4 / c2p_src / c2p_windowmono.c < prev    next >
C/C++ Source or Header  |  1999-01-01  |  16KB  |  568 lines

  1. /* :ts=4                            c2p_windowmono.c
  2.  *
  3.  *    cp4 - Commodore C+4 emulator
  4.  *    Copyright (C) 1998 Gáti Gergely
  5.  *
  6.  *    This program is free software; you can redistribute it and/or modify
  7.  *    it under the terms of the GNU General Public License as published by
  8.  *    the Free Software Foundation; either version 2 of the License, or
  9.  *    (at your option) any later version.
  10.  *
  11.  *    This program is distributed in the hope that it will be useful,
  12.  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.  *    GNU General Public License for more details.
  15.  *
  16.  *    You should have received a copy of the GNU General Public License
  17.  *    along with this program; if not, write to the Free Software Foundation,
  18.  *    Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  19.  *
  20.  *    e-mail: gatig@dragon.klte.hu
  21.  */
  22. #include <proto/graphics.h>
  23. #include <proto/exec.h>
  24. #include <proto/intuition.h>
  25. #include <exec/alerts.h>
  26. #include <intuition/pointerclass.h>
  27. #include <proto/gadtools.h>
  28. #include <proto/layers.h>
  29.  
  30. #include "cp4_ver.h"
  31.  
  32. #define C2P_VERSION        "1"
  33. #define C2P_REVISION    "3"
  34. #define C2P_AUTHOR        "gega <Gáti Gergely>"
  35. #define C2P_NAME        "WindowMono"
  36. #define C2P_DATE        DATE
  37. #define C2P_LOCALIZE
  38.  
  39. #include "c2p_module.c"
  40.  
  41. extern void REGARGS convfullasm(    REG(a0,void *chunkyaddr),
  42.                                     REG(a1,void *planaraddr) );
  43. extern void REGARGS convdeltaasm(    REG(a0,void *chunkyaddr),
  44.                                     REG(d0,void *delta),
  45.                                     REG(a1,void *planaraddr) );
  46.  
  47. struct GfxBase *GfxBase=NULL;
  48. struct IntuitionBase *IntuitionBase=NULL;
  49. struct Library *GadToolsBase=NULL;
  50. struct Library *LayersBase=NULL;
  51. static struct BitMap *bmap;
  52. static unsigned char *planar;
  53. static struct Window *win=NULL;
  54. static int offx=0,offy=0;
  55.     int bmx;
  56. static int maxx,maxy;
  57. static int borhoriz,borvert;
  58. static struct BitMap mybmap;
  59. static void *mypointer=NULL;
  60. static UWORD *mypntchip0=NULL;
  61. static UWORD *mypntchip1=NULL;
  62. static int winsleeped=0;
  63. static struct Requester InvisibleRequester;
  64. static struct Menu *mMenus=NULL;
  65. static APTR visualinfo=NULL;
  66. /* LORES-POINTER
  67.  */
  68. #define POINTERHEIGHT    31
  69. static UWORD pointerp0[]={
  70.     0,384,384,3504,3504,3504,28080,28080,28080,28086,28086,28086,32758,32758,32766,32766,
  71.     32764,16380,16376,16376,0,32764,0,32764,32740,32764,32740,32764,32764,32736,28672
  72. };
  73. static UWORD pointerp1[]={
  74.     384,960,4080,8184,8184,32760,65528,65528,65534,65535,65535,65535,65535,65535,65535,65535,
  75.     65534,32766,32764,32764,65534,65534,65534,32770,32794,32770,32794,32770,32770,32768,32768
  76. };
  77.  
  78. /* prefs
  79.  */
  80. static int WTop,WLeft,WHeight,WWidth,Wx,Wy;
  81. static char *WPubName=NULL;
  82.  
  83.  
  84. static char *initgfx(void);
  85. static void freegfx(void);
  86. static int mReset(struct IntuiMessage *imsg);
  87. static int mHReset(struct IntuiMessage *imsg);
  88. static int mDebug(struct IntuiMessage *imsg);
  89. static int mPrefs(struct IntuiMessage *imsg);
  90. static int mJump(struct IntuiMessage *imsg);
  91. static int mQuit(struct IntuiMessage *imsg);
  92.  
  93. #define MSG_PROJECT            0
  94. #define MSG_RESET            1
  95. #define MSG_HARDRESET        2
  96. #define MSG_DEBUG            3
  97. #define MSG_PREFS            4
  98. #define MSG_QUIT            5
  99. #define MSG_OPTIONS            6
  100. #define MSG_JUMPSCR            7
  101. #define MSG_INFO            8
  102. #define MSG_ERRVISUALINFO    9
  103. #define MSG_ERRCREATEMENU    10
  104. #define MSG_ERROPENWIN        11
  105. #define MSG_ERRBITMAPATTR    12
  106. #define MSG_ERRBITPNUM        13
  107. #define MSG_ERRFINDCOLMAP    14
  108. #define MSG_ERROBTPENS        15
  109. #define MSG_ERRGRAPHICS        16
  110. #define MSG_ERRINTUITION    17
  111. #define MSG_ERRLAYERS        18
  112. #define MSG_ERRGADTOOLS        19
  113. #define MSG_ERRPOINTER        20
  114. #define MSG_RESET_A            21
  115. #define MSG_HARDRESET_A        22
  116. #define MSG_DEBUG_A            23
  117. #define MSG_PREFS_A            24
  118. #define MSG_QUIT_A            25
  119. #define MSG_JUMPSCR_A        26
  120. #define MSG_NOMEM            27
  121.  
  122. static char *defstr[]={
  123.     "Project",
  124.     "Reset",
  125.     "HardReset",
  126.     "Debug...",
  127.     "Prefs...",
  128.     "Quit",
  129.     "Options",
  130.     "Jump PubScreen",
  131.     "Monochrome driver in a Workbench window. Works on OCS+",
  132.     "Can't find VisualInfo",
  133.     "Can't Create Menu",
  134.     "Can't open Window",
  135.     "Wrong BitMap Attributes",
  136.     "Wrong BitPlane Number",
  137.     "Can't Find ColorMap",
  138.     "Can't Obtain Pens",
  139.     "Can't open graphics.library V39",
  140.     "Can't open intuition.library V37",
  141.     "Can't open layers.library V33",
  142.     "Can't open gadtools.library V37",
  143.     "Can't Create Pointer",
  144.     "R",
  145.     "H",
  146.     "D",
  147.     "P",
  148.     "X",
  149.     "J",
  150.     "Not enough memory",
  151.     NULL
  152. };
  153.  
  154. /* Menu
  155.  */
  156. static struct NewMenu mNewMenu[]={
  157.     {    NM_TITLE, (STRPTR)MSG_PROJECT, NULL, 0, NULL, NULL    },
  158.     {    NM_ITEM, (STRPTR)MSG_RESET, (STRPTR)MSG_RESET_A, 0, 0L, (APTR)mReset },
  159.     {    NM_ITEM, (STRPTR)MSG_HARDRESET, (STRPTR)MSG_HARDRESET_A, 0, 0L, (APTR)mHReset },
  160.     {    NM_ITEM, (STRPTR)NM_BARLABEL, NULL, 0, 0L, NULL    },
  161.     {    NM_ITEM, (STRPTR)MSG_DEBUG, (STRPTR)MSG_DEBUG_A, 0, 0L, (APTR)mDebug },
  162.     {    NM_ITEM, (STRPTR)MSG_PREFS, (STRPTR)MSG_PREFS_A, 0, 0L, (APTR)mPrefs },
  163.     {    NM_ITEM, (STRPTR)NM_BARLABEL, NULL, 0, 0L, NULL    },
  164.     {    NM_ITEM, (STRPTR)MSG_QUIT, (STRPTR)MSG_QUIT_A, 0, 0L, (APTR)mQuit },
  165.     {    NM_TITLE, (STRPTR)MSG_OPTIONS, NULL, 0, NULL, NULL    },
  166.     {    NM_ITEM, (STRPTR)MSG_JUMPSCR, (STRPTR)MSG_JUMPSCR_A, 0, 0L, (APTR)mJump },
  167.     {    NM_END, NULL, NULL, 0, 0L, NULL    }
  168. };
  169. static struct NewMenu sNewMenu[]={
  170.     {    NM_TITLE, (STRPTR)MSG_PROJECT, NULL, 0, NULL, NULL    },
  171.     {    NM_ITEM, (STRPTR)MSG_RESET, (STRPTR)MSG_RESET_A, 0, 0L, (APTR)mReset },
  172.     {    NM_ITEM, (STRPTR)MSG_HARDRESET, (STRPTR)MSG_HARDRESET_A, 0, 0L, (APTR)mHReset },
  173.     {    NM_ITEM, (STRPTR)NM_BARLABEL, NULL, 0, 0L, NULL    },
  174.     {    NM_ITEM, (STRPTR)MSG_DEBUG, (STRPTR)MSG_DEBUG_A, 0, 0L, (APTR)mDebug },
  175.     {    NM_ITEM, (STRPTR)MSG_PREFS, (STRPTR)MSG_PREFS_A, 0, 0L, (APTR)mPrefs },
  176.     {    NM_ITEM, (STRPTR)NM_BARLABEL, NULL, 0, 0L, NULL    },
  177.     {    NM_ITEM, (STRPTR)MSG_QUIT, (STRPTR)MSG_QUIT_A, 0, 0L, (APTR)mQuit },
  178.     {    NM_TITLE, (STRPTR)MSG_OPTIONS, NULL, 0, NULL, NULL    },
  179.     {    NM_ITEM, (STRPTR)MSG_JUMPSCR, (STRPTR)MSG_JUMPSCR_A, 0, 0L, (APTR)mJump },
  180.     {    NM_END, NULL, NULL, 0, 0L, NULL    }
  181. };
  182.  
  183. char *SAVEDS minfo(void) {
  184. static char in[1024];
  185.     char *s;
  186.     c2p_OpenCatalog(defstr);
  187.     s=STR(MSG_INFO);
  188.     c2p_strncpy(in,s,1023);
  189.     c2p_CloseCatalog();
  190.     return(in);
  191. }
  192.  
  193. /* Handle MenuPick
  194.  */
  195. static int mReset(struct IntuiMessage *imsg) {
  196.     return(RET_RESET);
  197. } // mReset()
  198.  
  199. static int mHReset(struct IntuiMessage *imsg) {
  200.     return(RET_HRESET);
  201. } // mHReset()
  202.  
  203. static int mDebug(struct IntuiMessage *imsg) {
  204.     return(RET_DEBUG);
  205. } // mDebug()
  206.  
  207. static int mPrefs(struct IntuiMessage *imsg) {
  208.     return(RET_PREFS);
  209. } // mPrefs()
  210.  
  211. static int mQuit(struct IntuiMessage *imsg) {
  212.     return(RET_QUIT);
  213. } // mQuit()
  214.  
  215. static int mJump(struct IntuiMessage *imsg) {
  216. static char newname[MAXPUBSCREENNAME+1];
  217.     int r=RET_OK,i;
  218.     char *s;
  219.  
  220.     if(NULL!=(NextPubScreen(vec.c2p_Scr,newname))) {
  221.         if(NULL!=(s=AllocVec(MAXPUBSCREENNAME+1,MEMF_ANY))) {
  222.             freegfx();
  223.             r=RET_NEWWIN;
  224.             for(i=0;newname[i]!='\0';i++);
  225.             CopyMem(newname,s,i+1);
  226.             if(WPubName) FreeVec(WPubName);
  227.             WPubName=s;
  228.             if(NULL!=(initgfx())) {
  229.                 freegfx();
  230.                 // PANIC!!!
  231.                 Alert(AT_Recovery|AG_NoMemory|AO_Unknown);
  232.                 return(RET_ERROR);
  233.             }
  234.         }
  235.     }
  236.     return(r);
  237. } // mJump()
  238.  
  239.  
  240. static INLINE void calcwinsizes() {
  241.     borhoriz=win->BorderRight+win->BorderLeft-1;
  242.     borvert=win->BorderTop+win->BorderBottom-1;
  243.     maxx=SCRWIDTH-(win->Width-borhoriz);
  244.     maxy=SCRHEIGHT-(win->Height-borvert);
  245.     if(offx>maxx) {
  246.         ScrollLayer(0,win->RPort->Layer,-(offx-maxx),0);
  247.         offx=maxx;
  248.     }
  249.     if(offy>maxy) {
  250.         ScrollLayer(0,win->RPort->Layer,0,-(offy-maxy));
  251.         offy=maxy;
  252.     }
  253. }
  254.  
  255.  
  256. static char *initgfx(void) {
  257. static char pname[MAXPUBSCREENNAME+1];
  258.     int i,mx,my;
  259.     ULONG wa_top=WA_Top;
  260.  
  261.     /* Allocate bitmaps
  262.      */
  263.     if(NULL==(bmap=AllocBitMap(SCRWIDTH,SCRHEIGHT,1,BMF_DISPLAYABLE|BMF_CLEAR,NULL))) return(STR(MSG_NOMEM));
  264.     bmx=GetBitMapAttr(bmap,BMA_WIDTH)/8;
  265.     planar=(unsigned char *)bmap->Planes[0];
  266.  
  267.     /* Get the required PubScreen
  268.      */
  269.     if(NULL==(vec.c2p_Scr=LockPubScreen(WPubName))) {
  270.         vec.c2p_Scr=LockPubScreen(NULL);
  271.         GetDefaultPubScreen(pname);
  272.         if(WPubName) FreeVec(WPubName);
  273.         for(i=0;pname[i]!='\0';i++);
  274.         if(NULL==(WPubName=AllocVec(i+2,MEMF_ANY))) return(STR(MSG_NOMEM));
  275.         CopyMem(pname,WPubName,i+1);
  276.     }
  277.  
  278.     /* ScreenToFront
  279.      */
  280.     ScreenToFront(vec.c2p_Scr);
  281.  
  282.     /* Get Screen Attribs
  283.      */
  284.     if(!(visualinfo=GetVisualInfo(vec.c2p_Scr,TAG_DONE))) return(STR(MSG_ERRVISUALINFO));
  285.  
  286.     /* SetUp Menu
  287.      */
  288.     for(i=0;sNewMenu[i].nm_Type!=NM_END;i++) {
  289.         mNewMenu[i].nm_Label=sNewMenu[i].nm_Label;
  290.         mNewMenu[i].nm_CommKey=sNewMenu[i].nm_CommKey;
  291.     }
  292.     for(i=0;mNewMenu[i].nm_Type!=NM_END;i++) {
  293.         if(mNewMenu[i].nm_Label!=NM_BARLABEL) mNewMenu[i].nm_Label=STR((long)mNewMenu[i].nm_Label);
  294.         if(mNewMenu[i].nm_CommKey!=NULL) mNewMenu[i].nm_CommKey=STR((long)mNewMenu[i].nm_CommKey);
  295.     }
  296.     if(!(mMenus=CreateMenus(mNewMenu,GTMN_FrontPen,0L,TAG_DONE,0L))) return(STR(MSG_ERRCREATEMENU));
  297.     LayoutMenus(mMenus,visualinfo,GTMN_TextAttr,(ULONG)vec.c2p_Scr->Font,GTMN_NewLookMenus,TRUE,TAG_DONE,0L);
  298.  
  299.     /* Open window
  300.      */
  301.     if(WTop==-1) { wa_top=TAG_IGNORE; WTop=0; }
  302.     if((win=(struct Window *)OpenWindowTags(NULL,
  303.                 WA_Left, WLeft,
  304.                 wa_top, WTop,
  305.                 WA_Width, WWidth,
  306.                 WA_Height, WHeight,
  307.                 WA_Title, (ULONG)"WindowMono",
  308.                 WA_Flags,    WFLG_SIZEGADGET|
  309.                             WFLG_SIZEBBOTTOM|
  310.                             WFLG_DRAGBAR|
  311.                             WFLG_DEPTHGADGET|
  312.                             WFLG_CLOSEGADGET|
  313.                             WFLG_SUPER_BITMAP|
  314.                             WFLG_GIMMEZEROZERO|
  315.                             WFLG_ACTIVATE,
  316.                 WA_SuperBitMap, (ULONG)bmap,
  317.                 WA_ScreenTitle, (ULONG)"cp4",
  318.                 WA_AutoAdjust, TRUE,
  319.                 WA_RptQueue, 25,
  320.                 WA_IDCMP,    IDCMP_MOUSEMOVE|
  321.                             IDCMP_CLOSEWINDOW|
  322.                             IDCMP_MENUPICK|
  323.                             IDCMP_NEWSIZE|
  324.                             IDCMP_MOUSEBUTTONS,
  325.                 WA_PubScreen, (ULONG)vec.c2p_Scr,
  326.                 WA_PubScreenFallBack, TRUE,
  327.                 WA_NewLookMenus, TRUE,
  328.                 TAG_DONE,0L ))==NULL)
  329.         return(STR(MSG_ERROPENWIN));
  330.     SetMenuStrip(win,mMenus);
  331.     vec.c2p_Win=win;
  332.     winsleeped=0;
  333.     offx=offy=0;
  334.     calcwinsizes();
  335.     WindowLimits(win,borhoriz+80,borvert+20,SCRWIDTH+borhoriz,borvert+SCRHEIGHT);
  336.     offx+=Wx;        offy+=Wy;
  337.     mx=Wx;            my=Wy;
  338.     if(offx<0)        { mx-=offx; offx=0; }
  339.     if(offx>maxx)    { mx-=offx-maxx; offx=maxx; }
  340.     if(offy<0)        { my-=offy; offy=0; }
  341.     if(offy>maxy)    { my-=offy-maxy; offy=maxy; }
  342.     ScrollLayer(0,win->RPort->Layer,mx,my);
  343.     return(NULL);
  344. } // initgfx()
  345.  
  346.  
  347. static void freegfx(void) {
  348.     mawake();
  349.     if(GfxBase) WaitTOF();
  350.     if(win) {
  351.         WTop=win->TopEdge;
  352.         WLeft=win->LeftEdge;
  353.         WHeight=win->Height;
  354.         WWidth=win->Width;
  355.         vec.c2p_AddOptionInt("WINTOP",WTop);
  356.         vec.c2p_AddOptionInt("WINLEFT",WLeft);
  357.         vec.c2p_AddOptionInt("WINHEIGHT",WHeight);
  358.         vec.c2p_AddOptionInt("WINWIDTH",WWidth);
  359.         Wx=offx;
  360.         Wy=offy;
  361.         vec.c2p_AddOptionInt("OFFX",Wx);
  362.         vec.c2p_AddOptionInt("OFFY",Wy);
  363.         ClearMenuStrip(win);
  364.         CloseWindow(win);
  365.         win=NULL;
  366.     }
  367.     vec.c2p_Win=NULL;
  368.     if(mMenus) { FreeMenus(mMenus); mMenus=NULL; }
  369.     if(visualinfo) { FreeVisualInfo(visualinfo); visualinfo=NULL; }
  370.     if(vec.c2p_Scr) {
  371.         vec.c2p_AddOptionStr("PUBSCREEN",WPubName);
  372.         UnlockPubScreen(NULL,vec.c2p_Scr);
  373.         vec.c2p_Scr=NULL;
  374.     }
  375.     if(bmap) { FreeBitMap(bmap); bmap=NULL; }
  376. } // freegfx()
  377.  
  378.  
  379. char *SAVEDS minit(ULONG scrmode, ULONG overscan, unsigned char *linedeltatab) {
  380.     int i;
  381.     char *s;
  382.  
  383.     c2p_OpenCatalog(defstr);
  384.  
  385.     if(!(GfxBase=(struct GfxBase *)OpenLibrary("graphics.library",39))) return(STR(MSG_ERRGRAPHICS));
  386.     if(!(IntuitionBase=(struct IntuitionBase *)OpenLibrary("intuition.library",37))) return(STR(MSG_ERRINTUITION));
  387.     if(!(GadToolsBase=OpenLibrary("gadtools.library",37))) return(STR(MSG_ERRGADTOOLS));
  388.     if(!(LayersBase=OpenLibrary("layers.library",33))) return(STR(MSG_ERRLAYERS));
  389.  
  390.     /* Set up pointer
  391.      */
  392.     if(NULL==(mypntchip0=AllocVec((POINTERHEIGHT+1)*2,MEMF_CHIP))) return(STR(MSG_NOMEM));
  393.     if(NULL==(mypntchip1=AllocVec((POINTERHEIGHT+1)*2,MEMF_CHIP))) return(STR(MSG_NOMEM));
  394.     CopyMem(pointerp0,mypntchip0,2*POINTERHEIGHT);
  395.     CopyMem(pointerp1,mypntchip1,2*POINTERHEIGHT);
  396.     InitBitMap(&mybmap,2,16,POINTERHEIGHT);
  397.     mybmap.Planes[0]=(PLANEPTR)mypntchip0;
  398.     mybmap.Planes[1]=(PLANEPTR)mypntchip1;
  399.     mypointer=NewObject(NULL,"pointerclass",
  400.         POINTERA_BitMap, (ULONG)&mybmap,
  401.         POINTERA_XOffset, -6,
  402.         POINTERA_WordWidth, 1,
  403.         POINTERA_XResolution, POINTERXRESN_SCREENRES,
  404.         POINTERA_YResolution, POINTERYRESN_SCREENRES,
  405.         TAG_DONE );
  406.     if(mypointer==NULL) return(STR(MSG_ERRPOINTER));
  407.  
  408.     /* Get Options
  409.      */
  410.     Wx=vec.c2p_GetOptionInt("OFFX",0);
  411.     Wy=vec.c2p_GetOptionInt("OFFY",0);
  412.     WTop=vec.c2p_GetOptionInt("WINTOP",-1);
  413.     WLeft=vec.c2p_GetOptionInt("WINLEFT",0);
  414.     WHeight=vec.c2p_GetOptionInt("WINHEIGHT",303);
  415.     WWidth=vec.c2p_GetOptionInt("WINWIDTH",359);
  416.     s=vec.c2p_GetOptionStr("PUBSCREEN","Workbench");
  417.     for(i=0;s[i]!='\0';i++);
  418.     if(NULL==(WPubName=AllocVec(i+2,MEMF_ANY))) return(STR(MSG_NOMEM));
  419.     CopyMem(s,WPubName,i+1);
  420.  
  421.     return(initgfx());
  422. } // minit
  423.  
  424.  
  425. void SAVEDS mfree(void) {
  426.     freegfx();
  427.     if(mypntchip0) { FreeVec(mypntchip0); mypntchip0=NULL; }
  428.     if(mypntchip1) { FreeVec(mypntchip1); mypntchip1=NULL; }
  429.     if(mypointer) { DisposeObject(mypointer); mypointer=NULL; }
  430.     if(GfxBase) CloseLibrary((struct Library *)GfxBase);
  431.     if(IntuitionBase) { CloseLibrary((struct Library *)IntuitionBase); IntuitionBase=NULL; }
  432.     if(GadToolsBase) { CloseLibrary(GadToolsBase); GadToolsBase=NULL; }
  433.     if(LayersBase) CloseLibrary(LayersBase);
  434.     c2p_CloseCatalog();
  435.     return;
  436. } // free
  437.  
  438.  
  439. static INLINE int handleinput() {
  440.     struct IntuiMessage *imsg;
  441.     struct MenuItem *n;
  442.     int ret=RET_OK,move=0,lastx=0,lasty=0;
  443.     int (*func)(struct IntuiMessage *);
  444.  
  445.     while((imsg=(struct IntuiMessage *)RemHead(&vec.c2p_MsgList))) {
  446.         switch(imsg->Class) {
  447.             case IDCMP_CLOSEWINDOW :
  448.                 ret=RET_QUIT;
  449.                 break;
  450.             case IDCMP_NEWSIZE :
  451.                 calcwinsizes();
  452.                 break;
  453.             case IDCMP_MENUPICK :
  454.                 while(imsg->Code!=MENUNULL) {
  455.                     n=ItemAddress(mMenus,imsg->Code);
  456.                     func=(void *)(GTMENUITEM_USERDATA(n));
  457.                     ret=func(imsg);
  458.                     if(ret==RET_NEWWIN||ret==RET_ERROR) return(ret);
  459.                     imsg->Code=n->NextSelect;
  460.                 }
  461.                 break;
  462.             case IDCMP_MOUSEBUTTONS :
  463.                 if(imsg->Code==SELECTDOWN) {
  464.                     move=1;
  465.                     lastx=imsg->MouseX;
  466.                     lasty=imsg->MouseY;
  467.                 } else move=0;
  468.                 break;
  469.         }
  470.     }
  471.  
  472.     /* Handle Drag Window
  473.      */
  474.     if(move!=0) {
  475.         int mx,my,class,t1,t2;
  476.  
  477.         ReportMouse(TRUE,win);
  478.         SetWindowPointer(win,WA_Pointer,(ULONG)mypointer,TAG_DONE);
  479.         while(move!=0) {
  480.             WaitPort(win->UserPort);
  481.             imsg=(struct IntuiMessage *)GetMsg(win->UserPort);
  482.             mx=imsg->MouseX;
  483.             my=imsg->MouseY;
  484.             class=imsg->Class;
  485.             ReplyMsg((struct Message *)imsg);
  486.             switch(class) {
  487.                 case IDCMP_MOUSEBUTTONS :
  488.                     move=0;
  489.                     break;
  490.                 case IDCMP_MOUSEMOVE :
  491.                     offx+=lastx-mx;    offy+=lasty-my;
  492.                     t1=mx;            t2=my;
  493.                     mx=lastx-mx;    my=lasty-my;
  494.                     lastx=t1;        lasty=t2;
  495.                     if(offx<0)        { mx-=offx; offx=0; }
  496.                     if(offx>maxx)    { mx-=offx-maxx; offx=maxx; }
  497.                     if(offy<0)        { my-=offy; offy=0; }
  498.                     if(offy>maxy)    { my-=offy-maxy; offy=maxy; }
  499.                     ScrollLayer(0,win->RPort->Layer,mx,my);
  500.                     break;
  501.             }
  502.         }
  503.         SetWindowPointer(win,TAG_DONE);
  504.         ReportMouse(FALSE,win);
  505.     }
  506.  
  507.     return(ret);
  508. } // handleinput
  509.  
  510.  
  511. int SAVEDS mdo(unsigned char *chunky,unsigned char *delta,int numscreen) {
  512.     int ret;
  513.  
  514.     ret=handleinput();
  515.     if(ret!=RET_NEWWIN||ret!=RET_ERROR) {
  516.         convfullasm(chunky,planar);
  517.         LockLayerRom(win->RPort->Layer);
  518.         CopySBitMap(win->RPort->Layer);
  519.         UnlockLayerRom(win->RPort->Layer);
  520.     }
  521.     return(ret);
  522. } // do
  523.  
  524.  
  525. int SAVEDS mdofull(unsigned char *chunky,int numscreen) {
  526.     int ret;
  527.  
  528.     ret=handleinput();
  529.     if(ret!=RET_NEWWIN||ret!=RET_ERROR) {
  530.         convfullasm(chunky,planar);
  531.         LockLayerRom(win->RPort->Layer);
  532.         CopySBitMap(win->RPort->Layer);
  533.         UnlockLayerRom(win->RPort->Layer);
  534.     }
  535.     return(ret);
  536. } // dofull
  537.  
  538.  
  539. int SAVEDS mdont(void) {
  540.     int ret;
  541.  
  542.     /* handle input
  543.      */
  544.     ret=handleinput();
  545.     return(ret);
  546. } // dont
  547.  
  548.  
  549. void SAVEDS msleep(void) {
  550.     if(win) {
  551.         InitRequester(&InvisibleRequester);
  552.         Request(&InvisibleRequester,win);
  553.         SetWindowPointer(win,WA_BusyPointer,TRUE,TAG_DONE);
  554.         winsleeped=1;
  555.     }
  556. }
  557.  
  558.  
  559. void SAVEDS mawake(void) {
  560.     if(winsleeped) {
  561.         if(win) {
  562.             EndRequest(&InvisibleRequester,win);
  563.             SetWindowPointerA(win,NULL);
  564.             winsleeped=0;
  565.         }
  566.     }
  567. }
  568.